{
  "properties" : { },
  "id" : "dabc8a150c414241b87fdb7bbdd3d26f",
  "script" : null,
  "groupId" : "bcdec4ef1ba74815bea2c09a20056b65",
  "name" : "查询用户",
  "createTime" : 1714063371872,
  "updateTime" : 1712229838710,
  "lock" : null,
  "createBy" : "管理员",
  "updateBy" : "管理员",
  "path" : "list",
  "method" : "GET",
  "parameters" : [ {
    "name" : "username",
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }, {
    "name" : "name",
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }, {
    "name" : "unitId",
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : "1",
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "options" : [ {
    "name" : "permission",
    "value" : "system:uhgl",
    "description" : "允许拥有该权限的访问",
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : null,
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
import com.alibaba.fastjson.JSONObject;

var seSql = """
    SELECT 
        sur.*, sr.role_name FROM sys_user as sur 
        LEFT JOIN sys_unit_user_role as suur ON sur.user_id = suur.user_id
        LEFT JOIN sys_role AS sr ON sr.role_id = suur.role_id
    WHERE 
        suur.unit_id = #{unitId}
""";


if(username){
    seSql = seSql + " and username like '%${username}%'";
}
if(name){
    seSql = seSql + " and name like '%${name}%'";
}

if(orderProperty){
    seSql = seSql + " ORDER BY sur.`"+orderProperty+"` " + (orderSort? 'ASC': 'DESC');
}

return db.admin.page(seSql)